package com.shanzmoo.db.order.entity.dto;

import cn.hutool.core.util.NumberUtil;
import com.shanzmoo.db.product.entity.vo.SkuResultVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 门店订单明细保存对象
 * @author: Gzhao 2020/12/14
 */
@Data
@ApiModel("门店订单明细保存对象")
public class OutletOrderDetailSaveDto implements Serializable {

    private static final long serialVersionUID = 1758L;

    @ApiModelProperty(value = "订单号", hidden = true)
    private String orderNo;

    @ApiModelProperty(value = "商品类型: false-非标准商品，true-标准商品", example = "false")
    private Boolean type;

    @ApiModelProperty(value = "是否刷机：false-否，true-是", example = "true")
    private Boolean root;

    @ApiModelProperty(value = "商品sku", example = "123456")
    private String sku;

    @ApiModelProperty(value = "商品名称", example = "测试商品")
    private String skuName;

    @ApiModelProperty(value = "商品单位", example = "个")
    private String unit;

    @ApiModelProperty(value = "sku数量", example = "10")
    private Integer skuNum;

    @ApiModelProperty(value = "规格属性描述", example = "白色，128g")
    private String attributeDesc;

    @ApiModelProperty(value = "商品总价", example = "95")
    private BigDecimal totalPrice;

    @ApiModelProperty(value = "商品单价", example = "0.95")
    private BigDecimal unitPrice;

    @ApiModelProperty(value = "商品sn码", example = "123456798")
    private String snCode;

    public void fillAttribute(SkuResultVO skuResultVO) {
        this.skuName = skuResultVO.getSpuName();
        this.unit = skuResultVO.getUnitName();
        this.attributeDesc = skuResultVO.getAttributeDesc();
        this.unitPrice = skuResultVO.getOfflinePrice();
        this.totalPrice = NumberUtil.mul(this.getSkuNum(), this.unitPrice);
    }
}
